import type { JSX } from "react"
import { useSelector } from "react-redux"
import type { FilmState } from "../type/FilmStore"
import { Navigate } from "react-router-dom"

function RouterEnter (props: { element: JSX.Element }) {
  const { film } = useSelector((state: { film: FilmState }) => state.film)
  // console.log(film)
  if (!film.cityId) return <Navigate to='/city' />
  return props.element
}

export default RouterEnter
